/******************************************************************************
 * Copyright 2023 The Apollo Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *****************************************************************************/

#pragma once

#include "modules/canbus_vehicle/x3epro/proto/x3epro.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"

namespace apollo {
namespace canbus {
namespace x3epro {

class Scurearwheelspeed302 : public ::apollo::drivers::canbus::ProtocolData<
                    ::apollo::canbus::X3epro> {
 public:
  static const int32_t ID;
  Scurearwheelspeed302();
  void Parse(const std::uint8_t* bytes, int32_t length,
                     X3epro* chassis) const override;

 private:

    // config detail: {'bit': 7, 'enum': {0: 'FAILURERANK_NOMAL', 1: 'FAILURERANK_LEVEL_1', 2: 'FAILURERANK_LEVEL_2', 3: 'FAILURERANK_LEVEL_3', 4: 'FAILURERANK_LEVEL_4', 5: 'FAILURERANK_LEVEL_5', 6: 'FAILURERANK_RESERVED_6', 7: 'FAILURERANK_RESERVED_7'}, 'is_signed_var': False, 'len': 3, 'name': 'FailureRank', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'enum'}
    Scu_rearwheelspeed_302::FailurerankType failurerank(const std::uint8_t* bytes, const int32_t length) const;

    // config detail: {'bit': 4, 'is_signed_var': False, 'len': 13, 'name': 'VehicleSpeed_m', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'Km/h ->  m/s', 'precision': 0.05625, 'type': 'double'}
    double vehiclespeed_m(const std::uint8_t* bytes, const int32_t length) const;

    // config detail: {'bit': 23, 'enum': {0: 'WHEELSPEED_RL_INVALID', 1: 'WHEELSPEED_RL_VALID'}, 'is_signed_var': False, 'len': 1, 'name': 'WheelSpeed_RL_Valid', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'enum'}
    Scu_rearwheelspeed_302::Wheelspeed_rl_validType wheelspeed_rl_valid(const std::uint8_t* bytes, const int32_t length) const;

    // config detail: {'bit': 22, 'is_signed_var': False, 'len': 15, 'name': 'WheelSpeed_RL', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'Km/h ->  m/s', 'precision': 0.01, 'type': 'double'}
    double wheelspeed_rl(const std::uint8_t* bytes, const int32_t length) const;

    // config detail: {'bit': 39, 'enum': {0: 'WHEELSPEED_RR_INVALID', 1: 'WHEELSPEED_RR_VALID'}, 'is_signed_var': False, 'len': 1, 'name': 'WheelSpeed_RR_Valid', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'enum'}
    Scu_rearwheelspeed_302::Wheelspeed_rr_validType wheelspeed_rr_valid(const std::uint8_t* bytes, const int32_t length) const;

    // config detail: {'bit': 38, 'is_signed_var': False, 'len': 15, 'name': 'WheelSpeed_RR', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'Km/h ->  m/s', 'precision': 0.01, 'type': 'double'}
    double wheelspeed_rr(const std::uint8_t* bytes, const int32_t length) const;

    // config detail: {'bit': 51, 'is_signed_var': False, 'len': 4, 'name': 'AliveCounter_Rear', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'int'}
    int alivecounter_rear(const std::uint8_t* bytes, const int32_t length) const;

    // config detail: {'bit': 53, 'enum': {0: 'WHEELSPEED_RL_DIRECT_INVALID', 1: 'WHEELSPEED_RL_DIRECT_D', 2: 'WHEELSPEED_RL_DIRECT_N', 3: 'WHEELSPEED_RL_DIRECT_R'}, 'is_signed_var': False, 'len': 2, 'name': 'WheelSpeed_RL_Direct', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'enum'}
    Wheelspeed_directType wheelspeed_rl_direct(const std::uint8_t* bytes, const int32_t length) const;

    // config detail: {'bit': 55, 'enum': {0: 'WHEELSPEED_RR_DIRECT_INVALID', 1: 'WHEELSPEED_RR_DIRECT_D', 2: 'WHEELSPEED_RR_DIRECT_N', 3: 'WHEELSPEED_RR_DIRECT_R'}, 'is_signed_var': False, 'len': 2, 'name': 'WheelSpeed_RR_Direct', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'enum'}
    Wheelspeed_directType wheelspeed_rr_direct(const std::uint8_t* bytes, const int32_t length) const;

    // config detail: {'bit': 63, 'is_signed_var': False, 'len': 8, 'name': 'Checksum_Rear', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'int'}
    int checksum_rear(const std::uint8_t* bytes, const int32_t length) const;
};

}  // namespace x3epro
}  // namespace canbus
}  // namespace apollo


